import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Animation here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Animation extends Attachable
{
    /**
     * Act - do whatever the Animation wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    private final double RATE;
    private final GreenfootImage[] seq;
    private final int len;
    private double curr = 0;
    public Animation(GreenfootImage[] sequence, double rate){
        super(5,null);
        RATE = rate;
        seq = sequence;
        len = seq.length;
    }
    
    public void act() 
    {
     curr += RATE;
     int Rate = (int) curr;
     
     
     
     if(Rate >= len){
        getWorld().removeObject(this);
     }else{
        setImage(seq[Rate]);
        }
     super.act();  
    }    
}
